home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / syscall / Ioc_Lock.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-19  |  1.7 KB  |  59 lines

  1. /* 
  2.  * Ioc_Lock.c --
  3.  *
  4.  *    Source code for the Ioc_Lock library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: Ioc_Lock.c,v 1.1 88/06/19 14:29:19 ouster Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <sprite.h>
  21. #include <fs.h>
  22.  
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * Ioc_Lock --
  28.  *    Lock the device behind the stream.  The flags specify if the
  29.  *    lock is shared (IOC_LOCK_SHARED) or exclusive (IOC_LOCK_EXCLUSIVE).
  30.  *    A shared lock can co-exist with other shared locks, but not with
  31.  *    any exclusive locks.  Exclusive can't co-exist with any other locks.
  32.  *    If the lock can't be obtained right away, the process gets blocked
  33.  *    unless the IOC_LOCK_NO_BLOCK flag is specified.  In this case
  34.  *    FS_WOULD_BLOCK gets returned if the lock can't be taken.
  35.  *
  36.  * Results:
  37.  *    SUCCESS or FS_WOULD_BLOCK
  38.  *
  39.  * Side effects:
  40.  *    Grabs the lock associated with the device underlying the stream.
  41.  *
  42.  *----------------------------------------------------------------------
  43.  */
  44.  
  45. ReturnStatus
  46. Ioc_Lock(streamID, flags)
  47.     int streamID;
  48.     int flags;
  49. {
  50.     register ReturnStatus status;
  51.     Ioc_LockArgs args;
  52.  
  53.     args.flags = flags;
  54.  
  55.     status = Fs_IOControl(streamID, IOC_LOCK, sizeof(Ioc_LockArgs),
  56.             (Address)&args, 0, (Address)NULL);
  57.     return(status);
  58. }
  59.